From the beginning, Ollama was designed to be the cornerstone for applications that need AI. It makes running AI models on your local machine super easy and you don’t have to be an ML or AI expert to add amazing functionality to your app. You can interact with it directly with the amazing text ui, or you can use one of dozens, maybe even hundreds of other tools that leverage Ollama.
But sometimes to get those tools to work, you need to modify how the Ollama server runs. Maybe you need to set the ip address it is bound to, or allow different web origins. Maybe you want to disable the server pruning incomplete models because your network connection is crazy slow. Or you just need to set a proxy.
To do this you set an environment variable and there are a number of problems with that. Probably the biggest problem is that most people know how to set environment variables and they do it wrong, as far as the ollama server is concerned. You don’t want to set the environment variable for your shell, you need to set it for the ollama server, and the server isn’t run from your default shell.
So on systemd linux distros this is pretty straightforward. You create a new file in etc, / systemd, / system, / ollama.service.d called environment.conf and then add each environment variable you want to set to that file. Then reload systemd and restart ollama. if you aren’t a linux user, that may seem insane, but its pretty normal stuff.
But on Mac, until recently the recommendation was to stop the ollama server process from the menu bar, and then in a new terminal run ‘OLLAMA_HOST ip address and then ollama serve
’. And now you had to ensure your terminal was always running, and your log in .ollama/logs wouldn’t be there but instead would be in the terminal where ollama serve is running. This is super awkward.
Thankfully the process is a bit different now. Again, if you just set OLLAMA_HOST in your profile, Ollama serve won’t see it. But you can just run launchctl setenv OLLAMA_HOST ipaddress
and restart ollama and now ollama serve will see that. If you need to change that host, run that setenv command again and restart ollama.
The benefit here is that updates are updated as normal. your logs appear in .ollama/logs, you don’t have to ensure the terminal is open running your ollama serve command. It’s really super useful.
I hope you find this interesting and to get more tips like this, like and subscribe. If you have any questions, ask in the comments below. Thanks so much for watching, goodbye.!Set Environment Variables-leveled.wav